//
//  DemoListTableViewController.m
//  JPVideoPlayerDemo
//
//  Created by xin on 2018/4/12.
//  Copyright © 2018年 NewPan. All rights reserved.
//

#import "DemoListTableViewController.h"
#import "WBVideoPlayerViewController.h"
#import "DemoJPVideoPlayerCell.h"
#import "UIImageView+WebCache.h"

#import "UIView+WebVideoCache.h"
#import "UITableView+WebVideoCache.h"
#import "UITableViewCell+WebVideoCache.h"

@interface DemoListTableViewController ()

@end

@implementation DemoListTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"DemoJPVideoPlayerCell" bundle:nil] forCellReuseIdentifier:@"DemoJPVideoPlayerCell"];
    self.tableView.estimatedRowHeight = 200;
    [self.tableView reloadData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    DemoJPVideoPlayerCell *cell = [tableView dequeueReusableCellWithIdentifier:@"DemoJPVideoPlayerCell" forIndexPath:indexPath];
    
    NSString *url = @"https://ss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=304470494,1009502993&fm=27&gp=0.jpg";
    
    [cell.videoImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"placeholder1"] options:SDWebImageRetryFailed];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    WBVideoPlayerViewController *wb = [[WBVideoPlayerViewController alloc] initWithNibName:@"WBVideoPlayerViewController" bundle:nil];
    wb.hidesBottomBarWhenPushed = YES;
    wb.videoPath = @"http://p11s9kqxf.bkt.clouddn.com/iPhone.mp4";
    [self.navigationController pushViewController:wb animated:YES];
}

@end
